<%
  user = @user
  user_detail = user.thredded_user_detail
%>
<h1>
  <%= image_tag Thredded.avatar_url.call(user), class: 'thredded--user--avatar' %><%= user.thredded_display_name %>
</h1>
<ul>
  <% if user == current_user %>
    <%= link_to t('nav.edit_my_account'), edit_user_registration_path %>
  <% end %>
  <li><%= t 'thredded.users.user_since_html', time_ago: time_ago(user.created_at) %></li>
  <% if user_detail.last_seen_at %>
      <li><%= t 'thredded.users.last_active_html', time_ago: time_ago(user_detail.last_seen_at) %></li>
  <% end %>
  <% if user_detail.topics_count > 0 %>
      <li><%= t 'thredded.users.started_topics_count', count: user_detail.topics_count %></li>
  <% end %>
  <% if user_detail.posts_count > 0 %>
      <li><%= t 'thredded.users.posts_count', count: user_detail.posts_count %></li>
  <% end %>
</ul>
<% if current_user && current_user != user %>
  <a class="thredded--link"
     href="<%= Thredded::UrlsHelper.send_private_message_path(current_user: current_user, to: user) %>">
    <%= t 'thredded.users.send_private_message' %>
  </a>
<% end %>
<% posts_page = Thredded.posts_page_view(
    scope: user.thredded_posts.order_newest_first.limit(5),
    current_user: current_user) %>
<% if posts_page.present? %>
    <h2><%= t 'thredded.users.recent_activity' %></h2>
    <%= Thredded::ApplicationController.render partial: 'thredded/users/posts',
                                               locals: { posts: posts_page } %>
<% end %>
